package com.pengcheng.hnweb.util;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.pengcheng.hnweb.service.DbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

@Component
public class ExcelUtil {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private JsonUtil jsonUtil;
    public Map<String,Object> export(String filename,String table, List<Map<String,Object>> rows) throws Exception
    {
        Map<String,Object> res=new HashMap<>();
        if(table.equals("device"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=0";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("瞬时流量m³/H"));
            list.add(Arrays.asList("流速m/s"));
            list.add(Arrays.asList("累计流量m³"));
            list.add(Arrays.asList("正累计流量m³"));
            list.add(Arrays.asList("负累计流量m³"));
            list.add(Arrays.asList("口径mm"));
            list.add(Arrays.asList("液位m"));
            list.add(Arrays.asList("采集时间"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                Map<String,Object> row_dlog=(Map<String, Object>) row.get("row_dlog");
                d.add(row.get("id")==null?"":row.get("id").toString());
                d.add(row.get("new_longitude")==null?"":row.get("new_longitude").toString());
                d.add(row.get("new_latitude")==null?"":row.get("new_latitude").toString());
                d.add(row.get("name")==null?"":row.get("name").toString());
                d.add(row.get("sn")==null?"":row.get("sn").toString());
                d.add(row.get("state").toString().equals("0")?"离线":"在线");
                for(int j=0;j<rows_field.size();j++)
                {
                    if(Integer.parseInt(rows_field.get(j).get("show_list").toString())==1)
                    {
                        d.add(row.get("field_"+rows_field.get(j).get("id"))==null?"":row.get("field_"+rows_field.get(j).get("id")).toString());
                    }
                }
                if(row_dlog==null)
                {
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                }
                else {
                    BigDecimal flowrate=new BigDecimal(row_dlog.get("flowrate").toString());
                    BigDecimal speed=new BigDecimal(row_dlog.get("speed").toString());
                    BigDecimal flow=new BigDecimal(row_dlog.get("flow").toString());
                    BigDecimal p_flow=new BigDecimal(row_dlog.get("p_flow").toString());
                    BigDecimal n_flow=new BigDecimal(row_dlog.get("n_flow").toString());
                    BigDecimal caliber=new BigDecimal(row_dlog.get("caliber").toString());
                    BigDecimal flevel=new BigDecimal(row_dlog.get("flevel").toString());
                    flowrate=flowrate.divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP);
                    speed=speed.divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP);
                    flow=flow.setScale(3,RoundingMode.HALF_UP);
                    p_flow=p_flow.setScale(3,RoundingMode.HALF_UP);
                    n_flow=n_flow.setScale(3,RoundingMode.HALF_UP);
                    caliber=caliber.setScale(3,RoundingMode.HALF_UP);
                    flevel=flevel.setScale(3,RoundingMode.HALF_UP);
                    d.add(flowrate.toString());
                    d.add(speed.toString());
                    d.add(flow.toString());
                    d.add(p_flow.toString());
                    d.add(n_flow.toString());
                    d.add(caliber.toString());
                    d.add(flevel.toString());
                }
                d.add(row.get("last_date")==null?"":row.get("last_date").toString());
                data.add(d);
            }
            EasyExcel.write(filename).head(list).sheet(table).doWrite(data);
            res.put("code",1);
            res.put("msg","success");
        }
        else if(table.equals("alarm"))
        {
            JSONArray rows_alarm=JSONArray.parseArray(JSONArray.toJSONString(rows));
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("设备名称"));
            list.add(Arrays.asList("类型"));
            list.add(Arrays.asList("参数"));
            list.add(Arrays.asList("发生时间"));
            list.add(Arrays.asList("结束时间"));
            list.add(Arrays.asList("参数值"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                JSONObject row=rows_alarm.getJSONObject(i);
                JSONObject row_device=jsonUtil.get_jsonobject_by_path(row.toJSONString(),"$.row_device");
                int id= jsonUtil.get_int_by_path(row.toJSONString(),"$.id");
                String device_name=jsonUtil.get_string_by_path(row_device.toJSONString(),"$.name");
                int type= jsonUtil.get_int_by_path(row.toJSONString(),"$.type");
                String field= jsonUtil.get_string_by_path(row.toJSONString(),"$.field");
                double ftime= jsonUtil.get_double_by_path(row.toJSONString(),"$.ftime");
                double etime= jsonUtil.get_double_by_path(row.toJSONString(),"$.etime");
                String fdate= jsonUtil.get_string_by_path(row.toJSONString(),"$.fdate");
                String edate= jsonUtil.get_string_by_path(row.toJSONString(),"$.edate");
                String fval=jsonUtil.get_string_by_path(row.toJSONString(),"$.fval");
                int state= jsonUtil.get_int_by_path(row.toJSONString(),"$.state");
                String field_name="";
                if(field.equals("flowrate"))
                {
                    field_name="瞬时流量";
                }
                else if(field.equals("speed"))
                {
                    field_name="流速";
                }
                else if(field.equals("flow"))
                {
                    field_name="累计流量";
                }
                else if(field.equals("p_flow"))
                {
                    field_name="正累计流量";
                }
                else if(field.equals("n_flow"))
                {
                    field_name="负累计流量";
                }
                else if(field.equals("pressure"))
                {
                    field_name="压力";
                }
                else if(field.equals("caliber"))
                {
                    field_name="口径";
                }
                else if(field.equals("flevel"))
                {
                    field_name="液位";
                }
                else if(field.equals("temperature"))
                {
                    field_name="温度";
                }
                d.add(id+"");
                d.add(device_name);
                d.add(type==0?"设备掉线":"参数异常");
                d.add(field_name);
                d.add(fdate);
                d.add(etime>0?edate:"");
                d.add(type==1?fval:"");
                d.add(state==0?"持续中":"已结束");
                data.add(d);
            }
            EasyExcel.write(filename).head(list).sheet(table).doWrite(data);
            res.put("code",1);
            res.put("msg","success");
        }
        else
        {
            res.put("code",0);
            res.put("msg","不支持当前表");
        }
        return res;
    }

    public ExcelWriter get_builder(String filename, String table)
    {
        Map<String,Object> res=new HashMap<>();
        if(table.equals("device"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=0";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("瞬时流量m³/H"));
            list.add(Arrays.asList("流速m/s"));
            list.add(Arrays.asList("累计流量m³"));
            list.add(Arrays.asList("正累计流量m³"));
            list.add(Arrays.asList("负累计流量m³"));
            list.add(Arrays.asList("口径mm"));
            list.add(Arrays.asList("液位m"));
            list.add(Arrays.asList("采集时间"));
            list.add(Arrays.asList("物联网卡号"));
            list.add(Arrays.asList("固件版本"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("device_wq"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=6";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("当前值"));
            list.add(Arrays.asList("采集时间"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("device_level"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=7";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("当前值"));
            list.add(Arrays.asList("采集时间"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("device_rain"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=8";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("当前值"));
            list.add(Arrays.asList("采集时间"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("device_video"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=9";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("alarm"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("设备名称"));
            list.add(Arrays.asList("设备编号"));
            list.add(Arrays.asList("类型"));
            list.add(Arrays.asList("参数"));
            list.add(Arrays.asList("发生时间"));
            list.add(Arrays.asList("结束时间"));
            list.add(Arrays.asList("参数值"));
            list.add(Arrays.asList("状态"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("resource_info"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("设备数"));
            list.add(Arrays.asList("掉线数"));
            list.add(Arrays.asList("日期"));
            list.add(Arrays.asList("流量"));
            list.add(Arrays.asList("设备名称"));
            list.add(Arrays.asList("设备序列号"));
            list.add(Arrays.asList("状态"));
            list.add(Arrays.asList("设备流量"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("site"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=1 order by fsort asc";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("行政区域"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("计费开始月份"));
            list.add(Arrays.asList("水资源单价/m³"));
            list.add(Arrays.asList("重点监测"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("设备序号"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("permit"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("用水单位"));
            list.add(Arrays.asList("许可证编号"));
            list.add(Arrays.asList("许可证函号"));
            list.add(Arrays.asList("许可用水量"));
            list.add(Arrays.asList("开始日期"));
            list.add(Arrays.asList("结束日期"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("dayflow"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            list.add(Arrays.asList("设备ID"));
            list.add(Arrays.asList("设备"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("设备编号"));
            list.add(Arrays.asList("日期"));
            list.add(Arrays.asList("开始时间"));
            list.add(Arrays.asList("开始值"));
            list.add(Arrays.asList("结束时间"));
            list.add(Arrays.asList("结束值"));
            list.add(Arrays.asList("流量"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("monthflow"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            list.add(Arrays.asList("设备ID"));
            list.add(Arrays.asList("设备"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("设备编号"));
            list.add(Arrays.asList("月份"));
            list.add(Arrays.asList("流量"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("site_dayflow"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            list.add(Arrays.asList("用水单位"));
            list.add(Arrays.asList("日期"));
            list.add(Arrays.asList("流量"));
            return EasyExcel.write(filename).head(list).build();
        }
        else if(table.equals("site_monthflow"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            list.add(Arrays.asList("用水单位"));
            list.add(Arrays.asList("月份"));
            list.add(Arrays.asList("流量"));
            return EasyExcel.write(filename).head(list).build();
        }
        return null;
    }
    public List<List<String>> get_data(String table, List<Map<String,Object>> rows)
    {
        Map<String,Object> res=new HashMap<>();
        if(table.equals("device"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=0";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("瞬时流量m³/H"));
            list.add(Arrays.asList("流速m/s"));
            list.add(Arrays.asList("累计流量m³"));
            list.add(Arrays.asList("正累计流量m³"));
            list.add(Arrays.asList("负累计流量m³"));
            list.add(Arrays.asList("口径mm"));
            list.add(Arrays.asList("液位m"));
            list.add(Arrays.asList("采集时间"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                Map<String,Object> row_dlog=(Map<String, Object>) row.get("row_dlog");
                d.add(row.get("id")==null?"":row.get("id").toString());
                d.add(row.get("new_longitude")==null?"":row.get("new_longitude").toString());
                d.add(row.get("new_latitude")==null?"":row.get("new_latitude").toString());
                d.add(row.get("name")==null?"":row.get("name").toString());
                d.add(row.get("sn")==null?"":row.get("sn").toString());
                d.add(row.get("state").toString().equals("0")?"离线":"在线");
                for(int j=0;j<rows_field.size();j++)
                {
                    if(Integer.parseInt(rows_field.get(j).get("show_list").toString())==1)
                    {
                        d.add(row.get("field_"+rows_field.get(j).get("id"))==null?"":row.get("field_"+rows_field.get(j).get("id")).toString());
                    }
                }
                if(row_dlog==null)
                {
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                    d.add("");
                }
                else {
                    BigDecimal flowrate=new BigDecimal(row_dlog.get("flowrate").toString());
                    BigDecimal speed=new BigDecimal(row_dlog.get("speed").toString());
                    BigDecimal flow=new BigDecimal(row_dlog.get("flow").toString());
                    BigDecimal p_flow=new BigDecimal(row_dlog.get("p_flow").toString());
                    BigDecimal n_flow=new BigDecimal(row_dlog.get("n_flow").toString());
                    BigDecimal caliber=new BigDecimal(row_dlog.get("caliber").toString());
                    BigDecimal flevel=new BigDecimal(row_dlog.get("flevel").toString());
                    flowrate=flowrate.divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP);
                    speed=speed.divide(new BigDecimal(1000)).setScale(3, RoundingMode.HALF_UP);
                    flow=flow.setScale(3,RoundingMode.HALF_UP);
                    p_flow=p_flow.setScale(3,RoundingMode.HALF_UP);
                    n_flow=n_flow.setScale(3,RoundingMode.HALF_UP);
                    caliber=caliber.setScale(3,RoundingMode.HALF_UP);
                    flevel=flevel.setScale(3,RoundingMode.HALF_UP);
                    d.add(flowrate.toString());
                    d.add(speed.toString());
                    d.add(flow.toString());
                    d.add(p_flow.toString());
                    d.add(n_flow.toString());
                    d.add(caliber.toString());
                    d.add(flevel.toString());
                    d.add(row_dlog.get("ddate")+"");
                }
                d.add(row.get("iccd")==null?"":row.get("iccd").toString());
                d.add(row.get("version")==null?"":row.get("version").toString());
                data.add(d);
            }
            return data;
        }
        else if(table.equals("device_wq"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=6";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("当前值"));
            list.add(Arrays.asList("采集时间"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                Map<String,Object> row_dlog=(Map<String, Object>) row.get("row_dlog_wq");
                d.add(row.get("id")==null?"":row.get("id").toString());
                d.add(row.get("longitude")==null?"":row.get("longitude").toString());
                d.add(row.get("latitude")==null?"":row.get("latitude").toString());
                d.add(row.get("name")==null?"":row.get("name").toString());
                d.add(row.get("sn")==null?"":row.get("sn").toString());
                d.add(row.get("state").toString().equals("0")?"离线":"在线");
                for(int j=0;j<rows_field.size();j++)
                {
                    if(Integer.parseInt(rows_field.get(j).get("show_list").toString())==1)
                    {
                        d.add(row.get("field_"+rows_field.get(j).get("id"))==null?"":row.get("field_"+rows_field.get(j).get("id")).toString());
                    }
                }
                if(row_dlog==null)
                {
                    d.add("");
                    d.add("");
                }
                else {
                    BigDecimal val=new BigDecimal(row_dlog.get("val").toString());
                    d.add(val.toString());
                    d.add(row_dlog.get("fdate")==null?"":row_dlog.get("fdate").toString());
                }
                data.add(d);
            }
            return data;
        }
        else if(table.equals("device_level"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=7";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("当前值"));
            list.add(Arrays.asList("采集时间"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                Map<String,Object> row_dlog=(Map<String, Object>) row.get("row_dlog_wq");
                d.add(row.get("id")==null?"":row.get("id").toString());
                d.add(row.get("longitude")==null?"":row.get("longitude").toString());
                d.add(row.get("latitude")==null?"":row.get("latitude").toString());
                d.add(row.get("name")==null?"":row.get("name").toString());
                d.add(row.get("sn")==null?"":row.get("sn").toString());
                d.add(row.get("state").toString().equals("0")?"离线":"在线");
                for(int j=0;j<rows_field.size();j++)
                {
                    if(Integer.parseInt(rows_field.get(j).get("show_list").toString())==1)
                    {
                        d.add(row.get("field_"+rows_field.get(j).get("id"))==null?"":row.get("field_"+rows_field.get(j).get("id")).toString());
                    }
                }
                if(row_dlog==null)
                {
                    d.add("");
                    d.add("");
                }
                else {
                    BigDecimal val=new BigDecimal(row_dlog.get("val").toString());
                    d.add(val.toString());
                    d.add(row_dlog.get("fdate")==null?"":row_dlog.get("fdate").toString());
                }
                data.add(d);
            }
            return data;
        }
        else if(table.equals("device_rain"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=8";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("当前值"));
            list.add(Arrays.asList("采集时间"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                Map<String,Object> row_dlog=(Map<String, Object>) row.get("row_dlog_wq");
                d.add(row.get("id")==null?"":row.get("id").toString());
                d.add(row.get("longitude")==null?"":row.get("longitude").toString());
                d.add(row.get("latitude")==null?"":row.get("latitude").toString());
                d.add(row.get("name")==null?"":row.get("name").toString());
                d.add(row.get("sn")==null?"":row.get("sn").toString());
                d.add(row.get("state").toString().equals("0")?"离线":"在线");
                for(int j=0;j<rows_field.size();j++)
                {
                    if(Integer.parseInt(rows_field.get(j).get("show_list").toString())==1)
                    {
                        d.add(row.get("field_"+rows_field.get(j).get("id"))==null?"":row.get("field_"+rows_field.get(j).get("id")).toString());
                    }
                }
                if(row_dlog==null)
                {
                    d.add("");
                    d.add("");
                }
                else {
                    BigDecimal val=new BigDecimal(row_dlog.get("val").toString());
                    d.add(val.toString());
                    d.add(row_dlog.get("fdate")==null?"":row_dlog.get("fdate").toString());
                }
                data.add(d);
            }
            return data;
        }
        else if(table.equals("device_video"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=9";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                Map<String,Object> row_dlog=(Map<String, Object>) row.get("row_dlog_wq");
                d.add(row.get("id")==null?"":row.get("id").toString());
                d.add(row.get("longitude")==null?"":row.get("longitude").toString());
                d.add(row.get("latitude")==null?"":row.get("latitude").toString());
                d.add(row.get("name")==null?"":row.get("name").toString());
                d.add(row.get("sn")==null?"":row.get("sn").toString());
                d.add(row.get("state").toString().equals("0")?"离线":"在线");
                for(int j=0;j<rows_field.size();j++)
                {
                    if(Integer.parseInt(rows_field.get(j).get("show_list").toString())==1)
                    {
                        d.add(row.get("field_"+rows_field.get(j).get("id"))==null?"":row.get("field_"+rows_field.get(j).get("id")).toString());
                    }
                }
                data.add(d);
            }
            return data;
        }
        else if(table.equals("alarm"))
        {
            JSONArray rows_alarm=JSONArray.parseArray(JSONArray.toJSONString(rows));
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("设备名称"));
            list.add(Arrays.asList("类型"));
            list.add(Arrays.asList("参数"));
            list.add(Arrays.asList("发生时间"));
            list.add(Arrays.asList("结束时间"));
            list.add(Arrays.asList("参数值"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                JSONObject row=rows_alarm.getJSONObject(i);
                JSONObject row_device=jsonUtil.get_jsonobject_by_path(row.toJSONString(),"$.row_device");
                int id= jsonUtil.get_int_by_path(row.toJSONString(),"$.id");
                String device_name="";
                String device_no="";
                if(row_device!=null)
                {
                    device_name=jsonUtil.get_string_by_path(row_device.toJSONString(),"$.name");
                    device_no=jsonUtil.get_string_by_path(row_device.toJSONString(),"$.field_26");
                }
                int type= jsonUtil.get_int_by_path(row.toJSONString(),"$.type");
                String field= jsonUtil.get_string_by_path(row.toJSONString(),"$.field");
                double ftime= jsonUtil.get_double_by_path(row.toJSONString(),"$.ftime");
                double etime= jsonUtil.get_double_by_path(row.toJSONString(),"$.etime");
                String fdate= jsonUtil.get_string_by_path(row.toJSONString(),"$.fdate");
                String edate= jsonUtil.get_string_by_path(row.toJSONString(),"$.edate");
                String fval=jsonUtil.get_string_by_path(row.toJSONString(),"$.fval");
                int state= jsonUtil.get_int_by_path(row.toJSONString(),"$.state");
                String field_name="";
                if(field.equals("flowrate"))
                {
                    field_name="瞬时流量";
                }
                else if(field.equals("speed"))
                {
                    field_name="流速";
                }
                else if(field.equals("flow"))
                {
                    field_name="累计流量";
                }
                else if(field.equals("p_flow"))
                {
                    field_name="正累计流量";
                }
                else if(field.equals("n_flow"))
                {
                    field_name="负累计流量";
                }
                else if(field.equals("pressure"))
                {
                    field_name="压力";
                }
                else if(field.equals("caliber"))
                {
                    field_name="口径";
                }
                else if(field.equals("flevel"))
                {
                    field_name="液位";
                }
                else if(field.equals("temperature"))
                {
                    field_name="温度";
                }
                d.add(id+"");
                d.add(device_name);
                d.add(device_no);
                d.add(type==0?"设备掉线":"参数异常");
                d.add(field_name);
                d.add(fdate);
                d.add(etime>0?edate:"");
                d.add(type==1?fval:"");
                d.add(state==0?"持续中":"已结束");
                data.add(d);
            }
            return data;
        }
        else if(table.equals("site"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=1 order by fsort asc";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("行政区域"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("计费开始月份"));
            list.add(Arrays.asList("水资源单价/m³"));
            list.add(Arrays.asList("重点监测"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("设备序号"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                Map<String,Object> row_devision=(Map<String, Object>) row.get("row_division");
                d.add(row.get("id")==null?"":row.get("id").toString());
                if(row_devision==null)
                {
                    d.add("");
                }
                else {
                    d.add(row_devision.get("name")+"");
                }
                d.add(row.get("name")==null?"":row.get("name").toString());
                d.add(row.get("sdate")==null?"":row.get("sdate").toString());
                d.add(row.get("price")==null?"":row.get("price").toString());
                d.add(row.get("is_key")==null?"":row.get("is_key").toString());
                for(int j=0;j<rows_field.size();j++)
                {
                    if(Integer.parseInt(rows_field.get(j).get("show_list").toString())==1)
                    {
                        d.add(row.get("field_"+rows_field.get(j).get("id"))==null?"":row.get("field_"+rows_field.get(j).get("id")).toString());
                    }
                }
                List<Map<String,Object>> rows_device=(List<Map<String,Object>>) row.get("rows_device");
                String device_sns="";
                if(rows_device!=null)
                {
                    for(int j=0;j<rows_device.size();j++)
                    {
                        if(j>0)
                        {
                            device_sns+=",";
                        }
                        device_sns+=(rows_device.get(j).get("sn")+"");
                    }
                }
                d.add(device_sns);
                data.add(d);
            }
            return data;
        }
        else if(table.equals("permit"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=1 order by fsort asc";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("用水单位"));
            list.add(Arrays.asList("许可证编号"));
            list.add(Arrays.asList("许可证函号"));
            list.add(Arrays.asList("许可用水量"));
            list.add(Arrays.asList("开始日期"));
            list.add(Arrays.asList("结束日期"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                JSONObject r=JSONObject.parseObject(JSONObject.toJSONString(row));
                d.add(row.get("id")==null?"":row.get("id").toString());
                d.add(row.get("row_site")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_site.name"));
                d.add(row.get("fnumber")==null?"":row.get("fnumber").toString());
                d.add(row.get("fname")==null?"":row.get("fname").toString());
                d.add(row.get("flimit")==null?"":row.get("flimit").toString());
                d.add(row.get("sdate")==null?"":row.get("sdate").toString());
                d.add(row.get("edate")==null?"":row.get("edate").toString());
                data.add(d);
            }
            return data;
        }
        else if(table.equals("dayflow"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("设备ID"));
            list.add(Arrays.asList("设备"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("设备编号"));
            list.add(Arrays.asList("日期"));
            list.add(Arrays.asList("开始时间"));
            list.add(Arrays.asList("开始值"));
            list.add(Arrays.asList("结束时间"));
            list.add(Arrays.asList("结束值"));
            list.add(Arrays.asList("流量"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                JSONObject r=JSONObject.parseObject(JSONObject.toJSONString(row));
                d.add(row.get("id")==null?"":jsonUtil.get_int_by_path(r.toJSONString(),"$.id")+"");
                d.add(row.get("row_device")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_device.name"));
                d.add(row.get("row_device")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_device.sn"));
                d.add(row.get("row_device")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_device.field_26"));
                int dyear=jsonUtil.get_int_by_path(r.toJSONString(),"$.dyear");
                int dmonth=jsonUtil.get_int_by_path(r.toJSONString(),"$.dmonth");
                int dday=jsonUtil.get_int_by_path(r.toJSONString(),"$.dday");
                d.add(dyear+"-"+dmonth+"-"+dday);
                d.add(row.get("ddate2")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.ddate2"));
                d.add(row.get("flow2")==null?"":jsonUtil.get_double_by_path(r.toJSONString(),"$.flow2")+"");
                d.add(row.get("ddate1")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.ddate1"));
                d.add(row.get("flow1")==null?"":jsonUtil.get_double_by_path(r.toJSONString(),"$.flow1")+"");
                d.add(row.get("flow")==null?"":jsonUtil.get_double_by_path(r.toJSONString(),"$.flow")+"");
                data.add(d);
            }
            return data;
        }
        else if(table.equals("monthflow"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("设备ID"));
            list.add(Arrays.asList("设备"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("设备编号"));
            list.add(Arrays.asList("月份"));
            list.add(Arrays.asList("流量"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                JSONObject r=JSONObject.parseObject(JSONObject.toJSONString(row));
                d.add(row.get("id")==null?"":jsonUtil.get_int_by_path(r.toJSONString(),"$.id")+"");
                d.add(row.get("row_device")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_device.name"));
                d.add(row.get("row_device")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_device.sn"));
                d.add(row.get("row_device")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_device.field_26"));
                int dyear=jsonUtil.get_int_by_path(r.toJSONString(),"$.dyear");
                int dmonth=jsonUtil.get_int_by_path(r.toJSONString(),"$.dmonth");
                d.add(dyear+"-"+dmonth);
                d.add(row.get("flow")==null?"":jsonUtil.get_double_by_path(r.toJSONString(),"$.flow")+"");
                data.add(d);
            }
            return data;
        }
        else if(table.equals("site_dayflow"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("用水单位"));
            list.add(Arrays.asList("日期"));
            list.add(Arrays.asList("流量"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                JSONObject r=JSONObject.parseObject(JSONObject.toJSONString(row));
                d.add(row.get("row_site")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_site.name"));
                d.add(row.get("fdate")==null?"":row.get("fdate").toString());
                d.add(row.get("sum_flow")==null?"":row.get("sum_flow").toString());
                data.add(d);
            }
            return data;
        }
        else if(table.equals("site_monthflow"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("用水单位"));
            list.add(Arrays.asList("月份"));
            list.add(Arrays.asList("流量"));
            for(int i=0;i<rows.size();i++)
            {
                List<String> d=new ArrayList<>();
                Map<String,Object> row=rows.get(i);
                JSONObject r=JSONObject.parseObject(JSONObject.toJSONString(row));
                String dyear=row.get("dyear")==null?"":row.get("dyear").toString();
                String dmonth=row.get("dmonth")==null?"":row.get("dmonth").toString();
                d.add(row.get("row_site")==null?"":jsonUtil.get_string_by_path(r.toJSONString(),"$.row_site.name"));
                d.add(dyear+"-"+dmonth);
                d.add(row.get("sum_flow")==null?"":row.get("sum_flow").toString());
                data.add(d);
            }
            return data;
        }
        return null;
    }
    public boolean make_template(String filename, String table)
    {
        Map<String,Object> res=new HashMap<>();
        if(table.equals("device"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=0";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("经度"));
            list.add(Arrays.asList("纬度"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("序列号"));
            list.add(Arrays.asList("状态"));
            for(int i=0;i<rows_field.size();i++)
            {
                if(Integer.parseInt(rows_field.get(i).get("show_list").toString())==1)
                {
                    list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
                }
            }
            list.add(Arrays.asList("瞬时流量m³/H"));
            list.add(Arrays.asList("流速m/s"));
            list.add(Arrays.asList("累计流量m³"));
            list.add(Arrays.asList("正累计流量m³"));
            list.add(Arrays.asList("负累计流量m³"));
            list.add(Arrays.asList("口径mm"));
            list.add(Arrays.asList("液位m"));
            list.add(Arrays.asList("采集时间"));
            WriteSheet sheet= EasyExcel.writerSheet(table).build();
            EasyExcel.write(filename).head(list).build().write(data,sheet).finish();
        }
        else if(table.equals("alarm"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("设备名称"));
            list.add(Arrays.asList("设备编号"));
            list.add(Arrays.asList("类型"));
            list.add(Arrays.asList("参数"));
            list.add(Arrays.asList("发生时间"));
            list.add(Arrays.asList("结束时间"));
            list.add(Arrays.asList("参数值"));
            list.add(Arrays.asList("状态"));
            WriteSheet sheet= EasyExcel.writerSheet(table).build();
            EasyExcel.write(filename).head(list).build().write(data,sheet).finish();
        }
        else if(table.equals("resource_info"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("设备数"));
            list.add(Arrays.asList("掉线数"));
            list.add(Arrays.asList("日期"));
            list.add(Arrays.asList("流量"));
            list.add(Arrays.asList("设备名称"));
            list.add(Arrays.asList("设备序列号"));
            list.add(Arrays.asList("状态"));
            list.add(Arrays.asList("设备流量"));
            WriteSheet sheet= EasyExcel.writerSheet(table).build();
            EasyExcel.write(filename).head(list).build().write(data,sheet).finish();
        }
        else if(table.equals("site"))
        {
            String sql="select * from hnww_field where deleted=0 and ftype=1 order by fsort asc";
            List<Map<String,Object>> rows_field=jdbcTemplate.queryForList(sql);
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("行政区域"));
            list.add(Arrays.asList("名称"));
            list.add(Arrays.asList("计费开始月份"));
            list.add(Arrays.asList("水资源单价/m³"));
            list.add(Arrays.asList("重点监测"));
            for(int i=0;i<rows_field.size();i++)
            {
                list.add(Arrays.asList(rows_field.get(i).get("name").toString()));
            }
            list.add(Arrays.asList("设备序号"));
            WriteSheet sheet= EasyExcel.writerSheet(table).build();
            EasyExcel.write(filename).head(list).build().write(data,sheet).finish();
        }
        else if(table.equals("permit"))
        {
            List<List<String>> list = new ArrayList<List<String>>();
            List<List<String>> data = new ArrayList<List<String>>();
            list.add(Arrays.asList("ID"));
            list.add(Arrays.asList("用水单位"));
            list.add(Arrays.asList("许可证编号"));
            list.add(Arrays.asList("许可证函号"));
            list.add(Arrays.asList("许可用水量"));
            list.add(Arrays.asList("开始日期"));
            list.add(Arrays.asList("结束日期"));
            WriteSheet sheet= EasyExcel.writerSheet(table).build();
            EasyExcel.write(filename).head(list).build().write(data,sheet).finish();
        }
        else {
            return false;
        }
        return true;
    }
    public List<List<String>> get_resource_info_data(JSONArray rows)
    {
        Map<String,Object> res=new HashMap<>();
        List<List<String>> data = new ArrayList<List<String>>();
        for(int i=0;i<rows.size();i++)
        {
            JSONObject row=rows.getJSONObject(i);
            JSONArray rows_device=jsonUtil.get_jsonarray_by_path(row.toJSONString(),"$.rows_device");
            if(rows_device.size()==0)
            {
                List<String> d=new ArrayList<>();
                d.add(jsonUtil.get_int_by_path(row.toJSONString(),"$.id")+"");
                d.add(jsonUtil.get_string_by_path(row.toJSONString(),"$.name")+"");
                d.add(jsonUtil.get_jsonarray_by_path(row.toJSONString(),"$.rows_device").size()+"");
                d.add(jsonUtil.get_int_by_path(row.toJSONString(),"$.fcount_offline")+"");
                d.add(jsonUtil.get_string_by_path(row.toJSONString(),"$.flow_date")+"");
                d.add(jsonUtil.get_double_by_path(row.toJSONString(),"$.flow")+"");
                d.add("");
                d.add("");
                d.add("");
                d.add("");
                data.add(d);
            }
            for(int j=0;j<rows_device.size();j++)
            {
                JSONObject row_device=rows_device.getJSONObject(j);
                List<String> d=new ArrayList<>();
                d.add(jsonUtil.get_int_by_path(row.toJSONString(),"$.id")+"");
                d.add(jsonUtil.get_string_by_path(row.toJSONString(),"$.name")+"");
                d.add(jsonUtil.get_jsonarray_by_path(row.toJSONString(),"$.rows_device").size()+"");
                d.add(jsonUtil.get_int_by_path(row.toJSONString(),"$.fcount_offline")+"");
                d.add(jsonUtil.get_string_by_path(row.toJSONString(),"$.flow_date")+"");
                d.add(jsonUtil.get_double_by_path(row.toJSONString(),"$.flow")+"");
                d.add(jsonUtil.get_string_by_path(row_device.toJSONString(),"$.name")+"");
                d.add(jsonUtil.get_string_by_path(row_device.toJSONString(),"$.sn")+"");
                int state=jsonUtil.get_int_by_path(row_device.toJSONString(),"$.state");
                if(state==1)
                {
                    d.add("在线");
                }
                else {
                    d.add("离线");
                }
                d.add(jsonUtil.get_double_by_path(row_device.toJSONString(),"$.flow")+"");
                data.add(d);
            }
        }
        return data;
    }
    public List<Map<Integer,String>> read(String filename)
    {
        List<Map<Integer, String>> listMap = EasyExcel.read(filename).sheet().headRowNumber(0).doReadSync();
        return listMap;
    }
}
